//
//  ViewController.m
//  PullMenuDemo
//
//  Created by dapeng on 16/1/25.
//  Copyright © 2016年 dapeng. All rights reserved.
//

#import "ViewController.h"
#import "PullView.h"
@interface ViewController ()
@property (nonatomic, strong) UIButton *pullButton;
@property (nonatomic, strong) PullView *pullVC;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"切换增删频道";
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:[UIColor whiteColor]}];
    [self createPullView];
    [self createPullDownButton];
    
}

- (void)createPullView {
        self.pullVC = [[PullView alloc] initWithFrame:CGRectMake(0, 30, self.view.frame.size.width, self.view.frame.size.height)];
//        self.pullVC.pullDelegate = self;
        [self.view addSubview:self.pullVC];
//        self.pullVC.hidden = YES;
}

- (void)createPullDownButton {
    self.pullButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.pullButton.frame = CGRectMake(self.view.frame.size.width - 35, 64, 30, 30);
    [self.pullButton setImage:[UIImage imageNamed:@"pull_down"] forState:UIControlStateNormal];
    [self.pullButton setImage:[UIImage imageNamed:@"pull_down"] forState:UIControlStateSelected];
    [self.pullButton addTarget:self action:@selector(toPullViewController:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.pullButton];
}
static bool isClick = YES;

- (void)toPullViewController:(UIButton *)pull {
    self.pullButton.selected = !self.pullButton.selected;
    if (isClick == YES) {
        isClick = NO;

        self.pullVC.hidden = NO;
        self.pullButton.hidden = NO;
        [self.view bringSubviewToFront:self.pullVC];
        [self.view bringSubviewToFront:self.pullButton];
    }else {
        isClick = YES;
        self.pullVC.hidden = YES;
        self.pullButton.hidden = NO;
        
        
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
